import java.awt.Color;
import java.awt.Component;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

public class Applet extends java.applet.Applet implements Runnable, MouseListener,
	MouseMotionListener,
	KeyListener, FocusListener, WindowListener {
	private static final long serialVersionUID = -2586768225834163857L;
	private boolean aBoolean2 = false;
	private int anInt6;
	private int anInt7 = 20;
	public int anInt8 = 1;
	private long[] aLongArray9 = new long[10];
	public int anInt10;
	public boolean aBoolean11 = false;
	public int anInt12;
	public int anInt13;
	public Graphics aGraphics14;
	public GraphicsBuffer aGraphicsBuffer_15;
	public Sprite[] aSpriteArray16 = new Sprite[6];
	public Frame frame;
	public boolean aBoolean18 = true;
	public boolean aBoolean19 = true;
	public int anInt20;
	public int anInt21;
	public int anInt22;
	public int anInt23;
	public int anInt24;
	public int anInt25;
	public int anInt26;
	public long aLong27;
	public int anInt28;
	public int anInt29;
	public int anInt30;
	public long aLong31;
	public int[] anIntArray32 = new int[128];
	private int[] anIntArray33 = new int[128];
	private int anInt34;
	private int anInt35;
	public static int anInt36;

	public final void method1(int i, int i_0_, int i_1_) {
		anInt12 = i_1_;
		anInt13 = i_0_;
		frame = new Frame(this, anInt12, anInt13);
		if (i < 0) {
			aGraphics14 = method11().getGraphics();
			aGraphicsBuffer_15 = new GraphicsBuffer(anInt13, method11(), anInt12);
			method12(this, 1);
		}
	}

	public final void method2(int i, int i_2_, int i_3_) {
		anInt12 = i;
		if (i_3_ == 2) {
			anInt13 = i_2_;
			aGraphics14 = method11().getGraphics();
			aGraphicsBuffer_15 = new GraphicsBuffer(anInt13, method11(), anInt12);
			method12(this, 1);
		}
	}

	@Override
	public void run() {
		method11().addMouseListener(this);
		method11().addMouseMotionListener(this);
		method11().addKeyListener(this);
		method11().addFocusListener(this);
		if (frame != null) {
			frame.addWindowListener(this);
		}
		drawLoadingText(0, "Loading...");
		method6();
		int i = 0;
		int i_4_ = 256;
		int i_5_ = 1;
		int i_6_ = 0;
		int i_7_ = 0;
		for (int i_8_ = 0; i_8_ < 10; i_8_++) {
			aLongArray9[i_8_] = System.currentTimeMillis();
		}
		long l = System.currentTimeMillis();
		while (anInt6 >= 0) {
			if (anInt6 > 0) {
				anInt6--;
				if (anInt6 == 0) {
					method3(aBoolean2);
					return;
				}
			}
			int i_9_ = i_4_;
			int i_10_ = i_5_;
			i_4_ = 300;
			i_5_ = 1;
			l = System.currentTimeMillis();
			if (aLongArray9[i] == 0L) {
				i_4_ = i_9_;
				i_5_ = i_10_;
			} else if (l > aLongArray9[i]) {
				i_4_ = (int) ((anInt7 * 2560) / (l - aLongArray9[i]));
			}
			if (i_4_ < 25) {
				i_4_ = 25;
			}
			if (i_4_ > 256) {
				i_4_ = 256;
				i_5_ = (int) (anInt7 - (l - aLongArray9[i]) / 10L);
			}
			if (i_5_ > anInt7) {
				i_5_ = anInt7;
			}
			aLongArray9[i] = l;
			i = (i + 1) % 10;
			if (i_5_ > 1) {
				for (int i_11_ = 0; i_11_ < 10; i_11_++) {
					if (aLongArray9[i_11_] != 0L) {
						aLongArray9[i_11_] += i_5_;
					}
				}
			}
			if (i_5_ < anInt8) {
				i_5_ = anInt8;
			}
			try {
				Thread.sleep(i_5_);
			} catch (InterruptedException interruptedexception) {
				i_7_++;
			}
			for (/**/; i_6_ < 256; i_6_ += i_4_) {
				anInt28 = anInt24;
				anInt29 = anInt25;
				anInt30 = anInt26;
				aLong31 = aLong27;
				anInt24 = 0;
				method7();
				anInt34 = anInt35;
			}
			i_6_ &= 0xff;
			if (anInt7 > 0) {
				anInt10 = i_4_ * 1000 / (anInt7 * 256);
			}
			method9();
			if (aBoolean11) {
				System.out.println("ntime:" + l);
				for (int i_12_ = 0; i_12_ < 10; i_12_++) {
					int i_13_ = (i - i_12_ - 1 + 20) % 10;
					System.out.println("otim" + i_13_ + ":" + aLongArray9[i_13_]);
				}
				System.out.println("fps:" + anInt10 + " ratio:" + i_4_ + " count:" + i_6_);
				System.out.println("del:" + i_5_ + " deltime:" + anInt7 + " mindel:" + anInt8);
				System.out.println("intex:" + i_7_ + " opos:" + i);
				aBoolean11 = false;
				i_7_ = 0;
			}
		}
		if (anInt6 == -1) {
			method3(aBoolean2);
		}
	}

	public final void method3(boolean bool) {
		anInt6 = -2;
		method8(277);
		if (!bool) {
			if (frame != null) {
				try {
					Thread.sleep(1000L);
				} catch (Exception exception) {
					/* empty */
				}
				try {
					System.exit(0);
				} catch (Throwable throwable) {
					/* empty */
				}
			}
		}
	}

	public final void method4(int i_14_) {
		anInt7 = 1000 / i_14_;
	}

	@Override
	public final void start() {
		if (anInt6 >= 0) {
			anInt6 = 0;
		}
	}

	@Override
	public final void stop() {
		if (anInt6 >= 0) {
			anInt6 = 4000 / anInt7;
		}
	}

	@Override
	public final void destroy() {
		anInt6 = -1;
		try {
			Thread.sleep(10000L);
		} catch (Exception exception) {
			/* empty */
		}
		if (anInt6 == -1) {
			method3(aBoolean2);
		}
	}

	@Override
	public final void update(Graphics graphics) {
		if (aGraphics14 == null) {
			aGraphics14 = graphics;
		}
		aBoolean18 = true;
		method10();
	}

	@Override
	public final void paint(Graphics graphics) {
		if (aGraphics14 == null) {
			aGraphics14 = graphics;
		}
		aBoolean18 = true;
		method10();
	}

	@Override
	public final void mousePressed(MouseEvent mouseevent) {
		int i = mouseevent.getX();
		int i_15_ = mouseevent.getY();
		if (frame != null) {
			i -= 4;
			i_15_ -= 22;
		}
		anInt20 = 0;
		anInt25 = i;
		anInt26 = i_15_;
		aLong27 = System.currentTimeMillis();
		if (mouseevent.isMetaDown()) {
			anInt24 = 2;
			anInt21 = 2;
		} else {
			anInt24 = 1;
			anInt21 = 1;
		}
	}

	@Override
	public final void mouseReleased(MouseEvent mouseevent) {
		anInt20 = 0;
		anInt21 = 0;
	}

	@Override
	public final void mouseClicked(MouseEvent mouseevent) {
		/* empty */
	}

	@Override
	public final void mouseEntered(MouseEvent mouseevent) {
		/* empty */
	}

	@Override
	public final void mouseExited(MouseEvent mouseevent) {
		anInt20 = 0;
		anInt22 = -1;
		anInt23 = -1;
	}

	@Override
	public final void mouseDragged(MouseEvent mouseevent) {
		int i = mouseevent.getX();
		int i_16_ = mouseevent.getY();
		if (frame != null) {
			i -= 4;
			i_16_ -= 22;
		}
		anInt20 = 0;
		anInt22 = i;
		anInt23 = i_16_;
	}

	@Override
	public final void mouseMoved(MouseEvent mouseevent) {
		int i = mouseevent.getX();
		int i_17_ = mouseevent.getY();
		if (frame != null) {
			i -= 4;
			i_17_ -= 22;
		}
		anInt20 = 0;
		anInt22 = i;
		anInt23 = i_17_;
	}

	@Override
	public final void keyPressed(KeyEvent keyevent) {
		anInt20 = 0;
		int i = keyevent.getKeyCode();
		int i_18_ = keyevent.getKeyChar();
		if (i_18_ < 30) {
			i_18_ = 0;
		}
		if (i == 37) {
			i_18_ = 1;
		}
		if (i == 39) {
			i_18_ = 2;
		}
		if (i == 38) {
			i_18_ = 3;
		}
		if (i == 40) {
			i_18_ = 4;
		}
		if (i == 17) {
			i_18_ = 5;
		}
		if (i == 8) {
			i_18_ = 8;
		}
		if (i == 127) {
			i_18_ = 8;
		}
		if (i == 9) {
			i_18_ = 9;
		}
		if (i == 10) {
			i_18_ = 10;
		}
		if (i >= 112 && i <= 123) {
			i_18_ = i + 1008 - 112;
		}
		if (i == 36) {
			i_18_ = 1000;
		}
		if (i == 35) {
			i_18_ = 1001;
		}
		if (i == 33) {
			i_18_ = 1002;
		}
		if (i == 34) {
			i_18_ = 1003;
		}
		if (i_18_ > 0 && i_18_ < 128) {
			anIntArray32[i_18_] = 1;
		}
		if (i_18_ > 4) {
			anIntArray33[anInt35] = i_18_;
			anInt35 = anInt35 + 1 & 0x7f;
		}
	}

	@Override
	public final void keyReleased(KeyEvent keyevent) {
		anInt20 = 0;
		int i = keyevent.getKeyCode();
		char c = keyevent.getKeyChar();
		if (c < '\036') {
			c = '\0';
		}
		if (i == 37) {
			c = '\001';
		}
		if (i == 39) {
			c = '\002';
		}
		if (i == 38) {
			c = '\003';
		}
		if (i == 40) {
			c = '\004';
		}
		if (i == 17) {
			c = '\005';
		}
		if (i == 8) {
			c = '\010';
		}
		if (i == 127) {
			c = '\010';
		}
		if (i == 9) {
			c = '\t';
		}
		if (i == 10) {
			c = '\n';
		}
		if (c > 0 && c < '\u0080') {
			anIntArray32[c] = 0;
		}
	}

	@Override
	public final void keyTyped(KeyEvent keyevent) {
	}

	public final int method5() {
		int i_19_ = -1;
		if (anInt35 != anInt34) {
			i_19_ = anIntArray33[anInt34];
			anInt34 = anInt34 + 1 & 0x7f;
		}
		return i_19_;
	}

	@Override
	public final void focusGained(FocusEvent focusevent) {
		aBoolean19 = true;
		aBoolean18 = true;
		method10();
	}

	@Override
	public final void focusLost(FocusEvent focusevent) {
		aBoolean19 = false;
		for (int i = 0; i < 128; i++) {
			anIntArray32[i] = 0;
		}
	}

	@Override
	public final void windowActivated(WindowEvent windowevent) {
		/* empty */
	}

	@Override
	public final void windowClosed(WindowEvent windowevent) {
		/* empty */
	}

	@Override
	public final void windowClosing(WindowEvent windowevent) {
		destroy();
	}

	@Override
	public final void windowDeactivated(WindowEvent windowevent) {
		/* empty */
	}

	@Override
	public final void windowDeiconified(WindowEvent windowevent) {
		/* empty */
	}

	@Override
	public final void windowIconified(WindowEvent windowevent) {
		/* empty */
	}

	@Override
	public final void windowOpened(WindowEvent windowevent) {
		/* empty */
	}

	public void method6() {
	}

	public void method7() {
	}

	public void method8(int i) {
		i = 41 / i;
	}

	public void method9() {
	}

	public void method10() {
	}

	public Component method11() {
		if (frame != null) {
			return frame;
		}
		return this;
	}

	public void method12(Runnable runnable, int i) {
		Thread thread = new Thread(runnable);
		thread.start();
		thread.setPriority(i);
	}

	public void drawLoadingText(int i, String string) {
		while (aGraphics14 == null) {
			aGraphics14 = method11().getGraphics();
			try {
				method11().repaint();
			} catch (Exception exception) {
			}
			try {
				Thread.sleep(1000L);
			} catch (Exception exception) {
			}
		}
		java.awt.Font font = new java.awt.Font("Helvetica", 1, 13);
		FontMetrics fontmetrics = method11().getFontMetrics(font);
		java.awt.Font font_20_ = new java.awt.Font("Helvetica", 0, 13);
		method11().getFontMetrics(font_20_);
		if (aBoolean18) {
			aGraphics14.setColor(Color.black);
			aGraphics14.fillRect(0, 0, anInt12, anInt13);
			aBoolean18 = false;
		}
		Color color = new Color(140, 17, 17);
		int i_21_ = anInt13 / 2 - 18;
		aGraphics14.setColor(color);
		aGraphics14.drawRect(anInt12 / 2 - 152, i_21_, 304, 34);
		aGraphics14.fillRect(anInt12 / 2 - 150, i_21_ + 2, i * 3, 30);
		aGraphics14.setColor(Color.black);
		aGraphics14.fillRect(anInt12 / 2 - 150 + i * 3, i_21_ + 2, 300 - i * 3, 30);
		aGraphics14.setFont(font);
		aGraphics14.setColor(Color.white);
		aGraphics14.drawString(string, (anInt12 - fontmetrics.stringWidth(string)) / 2, i_21_ + 22);
	}
}
